<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-02 19:42:06
 * @LastEditTime: 2023-09-22 10:15:58
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description: 
 */

namespace App\Repositories;

use App\Models\Subject;

class SubjectRepository extends Repositories
    {
    public $relation_models = ['children', 'direct', 'status', 'parent','trade'];
    public function boot(Subject $model)
        {
        $this->model = $model;
        }

    public function getMenuList($parent_id = 0)
        {
        return $this->where('parent_id', $parent_id)->getList();
        }
    public function fuzzySearch($value)
        {
        $value = trim($value);
        $this->where(function ($query) use ($value)
            {
            $query->orWhere("name", "like", "%{$value}%");
            $query->orWhere("code", "like", "%{$value}%");
            });
        }
    }